package demo05.Consumer;

import java.util.function.Consumer;

/*
   Consumer接口的默认方法andThen
   作用:需要两个Consumer接口,可以把两个Consumer接口组合到一起,在对数据进行消费

   Consumer c1=new Consumer
   Consumer c2=new Consumer
   String s="张三"
   c1.accept(s);
   c2.accept(s);

   等价于
   c1.andThen(c2).accept(s);
 */
public class Demo02AndThen {
    public static void print(String s, Consumer<String> c1, Consumer<String> c2) {
        /*c1.accept(s);
        c2.accept(s);*/
        //可以用andThen来简化
        c1.andThen(c2).accept(s);
    }

    public static void main(String[] args) {
        print("JavaWorldFirst", (s) -> System.out.println(s.toLowerCase()), (s) -> System.out.println(s.toUpperCase()));
    }
}
